const fs = require('fs');  

class iifaaPlugin {  
  apply(compiler) {  
    console.log('////////////////////')
    compiler.hooks.done.tap('iifaaPlugin', (stats) => {  
      function iifaa() {  
        const paths = [  
          `${__dirname}/unpackage/dist/dev/mp-alipay/pages/special/index.axml`,  // dev环境编译后的文件路径  
          `${__dirname}/unpackage/dist/build/mp-alipay/pages/special/index.axml`,  // build环境编译后的文件路径  
        ];  
        paths.forEach((path) => {  
          if (fs.existsSync(path)) {  
            let content = fs.readFileSync(path).toString();  
            content = content.replace('iifaa-proof onRef=', 'iifaa-proof ref='); // 此处重点，将onRef替换成了小程序的语法  
            fs.writeFileSync(path, content);  
          }  
        });  
      }  

      iifaa();
    });  
  }  
}  

module.exports = {  
  configureWebpack: {  
    plugins: [new iifaaPlugin()],  
  },  
};  